module.exports = function(window, document) {
	var apivm = require('../../common/avm.min')(window, document);
	var avm = apivm;
	var api = apivm.api;
	var Component = apivm.Component;
	var $ = apivm.$;
	(function() {
	var StatusBarView = /*@__PURE__*/ (function(Component) {
		function StatusBarView(props) {
			Component.call(this, props);
			this.compute = {
				statusBarHeight: function() {
					if (api.safeArea) {
						return api.safeArea.top;
					} else {
						var res = wx.getSystemInfoSync();
						return res.statusBarHeight;
					}
				}
			};
		}

		if (Component) StatusBarView.__proto__ = Component;
		StatusBarView.prototype = Object.create(Component && Component.prototype);
		StatusBarView.prototype.constructor = StatusBarView;
		StatusBarView.prototype.render = function() {
			return apivm.h("view", {style: "height:" + this.statusBarHeight + "px;"});
		};

		return StatusBarView;
	})(Component);
	apivm.define("status-bar-view", StatusBarView);

	var Navigationbar = /*@__PURE__*/ (function(Component) {
		function Navigationbar(props) {
			Component.call(this, props);
		}

		if (Component) Navigationbar.__proto__ = Component;
		Navigationbar.prototype = Object.create(Component && Component.prototype);
		Navigationbar.prototype.constructor = Navigationbar;
		Navigationbar.prototype.onLeftButton = function(e) {
			api.closeWin();
		};
		Navigationbar.prototype.render = function() {
			return apivm.h(
				"view",
				{class: "nav-container"},
				apivm.h("status-bar-view", null),
				apivm.h(
					"view",
					{class: "nav-header"},
					apivm.h(
						"view",
						{
							class: "nav-header-button nav-left-button",
							onclick: this.props.onLeftButton
								? this.props.onLeftButton
								: this.onLeftButton
						},
						apivm.h("image", {
							width: this.props.leftButtonWidth ? this.props.leftButtonWidth : 11,
							src: this.props.leftButtonIcon
								? this.props.leftButtonIcon
								: "../../image/back.png",
							mode: "widthFix"
						}),
						apivm.h("text", {class: "nav-header-text"}, this.props.leftButtonText)
					),
					apivm.h("text", {class: "nav-header-title"}, this.props.title),
					apivm.h(
						"view",
						{
							class: "nav-header-button nav-right-button",
							onclick: this.props.onRightButton
						},
						apivm.h("image", {
							width: this.props.rightButtonWidth ? this.props.rightButtonWidth : 0,
							src: this.props.rightButtonIcon ? this.props.rightButtonIcon : "",
							mode: "widthFix"
						}),
						apivm.h("text", {class: "nav-header-text"}, this.props.rightButtonText)
					)
				)
			);
		};

		return Navigationbar;
	})(Component);
	apivm.define("navigationBar", Navigationbar);

	var Order = /*@__PURE__*/ (function(Component) {
		function Order(props) {
			Component.call(this, props);
			this.data = {
				dataList: [],
				count: 0,
				price: 0,
				totalPrice: 0,
				freight: 5.0,
				discounts: 0,
				addressInfo: {
					name: "APICloud",
					mobile: "15100000000",
					typeDesc: "公司",
					address: "中关村科技园区电子城科技园"
				},

				payList: [
					{
						icon: "../../image/icon_balance_pay.png",
						name: "余额支付",
						recommend: true
					},
					{
						icon: "../../image/icon_wxpay.png",
						name: "微信支付",
						recommend: true
					},
					{
						icon: "../../image/icon_alipay.png",
						name: "支付宝",
						recommend: false
					}
				],

				payMethod: "微信支付"
			};
		}

		if (Component) Order.__proto__ = Component;
		Order.prototype = Object.create(Component && Component.prototype);
		Order.prototype.constructor = Order;
		Order.prototype.apiready = function() {
			var amountValue = 0;
			var countValue = 0;
			var dataList = api.pageParam.dataList;
			this.data.dataList = dataList;
			for (var i = 0; i < dataList.length; i++) {
				countValue += parseInt(dataList[i].wareCount);
				amountValue +=
					parseFloat(dataList[i].price) * parseInt(dataList[i].wareCount);
			}
			amountValue = Math.round(amountValue * 10) / 10;
			this.data.count = countValue;
			this.data.price = amountValue;
			this.data.totalPrice = amountValue + this.data.freight;

			api.addEventListener(
				{
					name: "navitembtn"
				},
				function(ret) {
					if (ret.type == "left") {
						api.closeWin();
					}
				}
			);
		};
		Order.prototype.onpaymethodchange = function(e) {
			var name = e.currentTarget.dataset.name;
			if (this.data.payMethod != name) {
				this.data.payMethod = name;
			}
		};
		Order.prototype.fnBuy = function() {
			api.toast({
				msg: "演示版本，不能支付",
				location: "middle"
			});
		};
		Order.prototype.render = function() {
			var this$1 = this;
			return apivm.h(
				"view",
				{class: "main"},
				apivm.h("navigationBar", {title: "确认订单"}),
				apivm.h(
					"scroll-view",
					{class: "scrollView", "scroll-y": "true"},
					apivm.h(
						"view",
						{class: "info-addr"},
						apivm.h("image", {
							class: "addr-icon",
							src: "../../image/icon_address.png"
						}),
						apivm.h(
							"view",
							{class: "addr-middle"},
							apivm.h(
								"text",
								{class: "text-black"},
								"收货人: " +
									this.data.addressInfo.name +
									"   " +
									this.data.addressInfo.mobile
							),
							apivm.h(
								"view",
								{class: "addr-bottom"},
								apivm.h(
									"text",
									{class: "text-red"},
									"[" + this.data.addressInfo.typeDesc + "]"
								),
								apivm.h("text", {class: "text-grey"}, this.data.addressInfo.address)
							)
						),
						apivm.h("image", {
							class: "addr-arrow-icon",
							src: "../../image/item_user_address_right.png"
						})
					),
					apivm.h(
						"view",
						{class: "info-order"},
						apivm.h(
							"view",
							{class: "item-desc"},
							apivm.h("image", {
								class: "item-icon",
								src: "../../image/icon_order.png"
							}),
							apivm.h("text", {class: "text-black"}, "订单信息")
						),
						apivm.h(
							"view",
							null,
							Object.entries(this.data.dataList).map(function(ref) {
								var index$1 = ref[0];
								var item$1 = ref[1];
								return apivm.h(
									"view",
									{class: "wareItem"},
									apivm.h("image", {
										class: "thumbnail",
										src: item$1.thumbnail,
										placeholder: "../../image/default_square.png"
									}),
									apivm.h(
										"view",
										{class: "wareInfo"},
										apivm.h(
											"text",
											{class: "text-black"},
											item$1.name + " " + (item$1.unit || "")
										),
										apivm.h("text", {class: "text-black"}, "￥" + item$1.price)
									),
									apivm.h("text", {class: "info-wareCount"}, item$1.wareCount)
								);
							})
						),
						apivm.h(
							"view",
							{class: "list-item"},
							apivm.h("text", {class: "text-black"}, "数量："),
							apivm.h("text", {class: "text-black"}, this.data.count + "件")
						),
						apivm.h(
							"view",
							{class: "list-item"},
							apivm.h("text", {class: "text-black"}, "优惠券："),
							apivm.h(
								"view",
								{class: "list-item-coupon"},
								apivm.h("text", {class: "text-grey"}, "未使用 "),
								apivm.h("image", {
									style: "width:9px;height:14px;",
									src: "../../image/arrow_right.png"
								})
							)
						),
						apivm.h(
							"view",
							{class: "list-item"},
							apivm.h("text", {class: "text-black"}, "商品金额："),
							apivm.h("text", {class: "text-red"}, "+ ￥" + this.data.price)
						),
						apivm.h(
							"view",
							{class: "list-item"},
							apivm.h("text", {class: "text-black"}, "运费："),
							apivm.h("text", {class: "text-red"}, "+ ￥" + this.data.freight)
						),
						apivm.h(
							"view",
							{class: "list-item"},
							apivm.h("text", {class: "text-black"}, "优惠金额："),
							apivm.h("text", {class: "text-red"}, "- ￥" + this.data.discounts)
						),
						apivm.h(
							"view",
							{class: "list-item-totalPrice"},
							apivm.h("text", {class: "text-black"}, "实付款："),
							apivm.h("text", {class: "text-red"}, "￥" + this.data.totalPrice)
						)
					),
					apivm.h(
						"view",
						{class: "info-pay"},
						apivm.h(
							"view",
							{class: "item-desc"},
							apivm.h("image", {class: "item-icon", src: "../../image/order_pay.png"}),
							apivm.h("text", {class: "text-black"}, "付款方式")
						),
						Object.entries(this.data.payList).map(function(ref) {
							var index$1 = ref[0];
							var item$1 = ref[1];
							return apivm.h(
								"view",
								{
									class: "list-item",
									"data-name": item$1.name,
									onclick: function(event) {
										if (this$1.onpaymethodchange) {
											this$1.onpaymethodchange(event);
										} else {
											onpaymethodchange(event);
										}
									}
								},
								apivm.h(
									"view",
									{class: "pay-left"},
									apivm.h("image", {class: "payIcon", src: item$1.icon}),
									apivm.h("text", {class: "payName"}, item$1.name),
									item$1.recommend
										? apivm.h("image", {
												style: "width:17px;height:17px;",
												src: "../../image/recommend.png"
										  })
										: null
								),
								apivm.h("image", {
									style: "width:25px;height:25px;",
									src:
										item$1.name == this$1.data.payMethod
											? "../../image/order_on.png"
											: "../../image/order_off.png"
								})
							);
						})
					)
				),
				apivm.h(
					"view",
					{class: "footer"},
					apivm.h(
						"text",
						{class: "footer-price"},
						"总金额: ￥" + this.data.totalPrice
					),
					apivm.h("image", {
						src: "../../image/confirm.png",
						class: "buy-button",
						onclick: function(event) {
							if (this$1.fnBuy) {
								this$1.fnBuy();
							} else {
								fnBuy();
							}
						}
					})
				),
				apivm.h("safe-area", {class: "safe-area"})
			);
		};

		return Order;
	})(Component);
	apivm.define("order", Order);
	apivm.render(apivm.h("order", null), "body");
})();

	window['createApp'] = function() {
		apivm.$_start();
	}
	return avm;
}